// Copyright (c) 2014 by xhhjin. All rights reserved.

// Avoid 'chrome' namespace
var isChrome = false; //On Chrome
if (typeof browser === "undefined" && typeof chrome === "object") {
  var browser = chrome; //On Chrome
  isChrome = true;
}

function ghost(isDeactivated) {
  options.style.color = isDeactivated ? 'graytext' : 'black';
}

window.addEventListener('load', function () {
  browser.storage.local.get(null, function (result) {
    // Initialize the option controls.
    options.CopyFileNameNoExtension.checked = JSON.parse(result["CopyFileNameNoExtension"]);

    if (!options.CopyFileNameNoExtension.checked) { ghost(true); }

    // Set the display activation and frequency.
    options.CopyFileNameNoExtension.onchange = function () {
      browser.storage.local.set({ "CopyFileNameNoExtension": options.CopyFileNameNoExtension.checked });
      ghost(!options.CopyFileNameNoExtension.checked);
    };
  });
});
